<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var str = "abcder"; //string
    var str = new String("asdasda"); //object

    str.charAt(3);//a
    str.charCodeAt(3);//97

    String.fromCharCode(97); //"a"

    str.indexOf("d");//2
    str.indexOf("d", 3);//5

    str.search("d"); //2 

    var str = new String("asdasda"); //object
    var reg = /D/ig;

    var result = str.search(/D/ig);
    console.log(result);


    // var result = str.match("d");
    var result = str.match(/d/ig);
    console.log(result);

    var result = str.replace("d", "f");
    var result = str.replace(/asd/ig, "f");
    console.log(result);

    var str = new String("asdasda"); //object
    //裁切,截取
    //  slice(startIndex,endIndex);    str.substring()
    // console.log(str.slice(0, -1))   //str.length -1

    // str.substr(startIndex,length);

    // 拼接
    str.concat(",", "day day up");
    str + "," + "day day up";


    // 转大写
    console.log(str.toUpperCase());
    console.log(str.toLowerCase());

    str.trim();
    // btn.onclick = function () {
    //     console.log(666666666);
    // }
    // btn.onclick();

    // 先声明在赋值
    // var obj = {};  // json
    // obj.name = "abc";
    // obj["age"] = 20;

    // 声明得同时赋值
    var obj = {
        name: "abc",
        age: 20,
        isTrue: true,
        money: null,
        hobby: ["唱歌", "跳舞", "打篮球"]
    }

    obj.say = function () {
        console.log(666666666);
    }


    console.log(obj);

    obj.say();

    console.log(obj.hobby);


    obj = null;





</script>

</html>